package at.rtm.domain;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;


/**
 * TemperatureDAO domain object. A calendar object is associated with a temperature.
 */
public class Temperature {
    private Long id;
    private Calendar cal;
    private Double temperature;

    public Temperature(Calendar cal, Double temperature) {
        this(-1l, cal, temperature);
    }

    public Temperature(Long id, Calendar cal, Double temperature) {
        this(id, cal.getTime(), temperature);
    }

    public Temperature(Long id, Date date, Double temperature) {
        this.id = id;
        this.cal = new GregorianCalendar();
        this.cal.setTime(date);
        this.temperature = temperature;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Calendar getCal() {
        return cal;
    }

    public void setCal(Calendar cal) {
        this.cal = cal;
    }

    public Double getTemperature() {
        return temperature;
    }

    public void setTemperature(Double temperature) {
        this.temperature = temperature;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Temperature that = (Temperature) o;

        if (id != null ? !id.equals(that.id) : that.id != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return id != null ? id.hashCode() : 0;
    }
}
